//
//  CocOthAppDelegate.m
//  CocOth
//
//  Created by BrunoCausse on 03/11/10.
//  Copyright 2010-2013 poulailler cie. All rights reserved.
//

#import "CocOthAppDelegate.h"
#import "CocOthAppController.h"



#import "BC_Utils.h"

@implementation CocOthAppDelegate

@synthesize window;

#pragma mark Delegate Application

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
	// Insert code here to initialize your application
		
}

- (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) theApplication
{
	
	return YES;
}

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
//	NSLog(@"applicationShouldTerminate");

	[appController disconnect];
	
	return YES;
}	

#pragma mark Delegate Window

- (void) windowWillClose: (NSNotification *) notification
{
	[[window windowController] setShouldCascadeWindows:NO]; // Tell the controller to not cascade its windows.
	
	[window setFrameAutosaveName:[window representedFilename]];  // Specify the autosave name for the window.
}



-(NSSize) windowWillResize:(NSWindow *)sender
					toSize:(NSSize)frameSize
{
	
	NSSize newSize;
	int size = min(frameSize.width, frameSize.height);
	newSize.width  = size; 
	newSize.height = size + 20;//hauteur de la barre de titre
		
	return newSize;
}

- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
	[appController openFile:filename];
	return YES;
}


@end
